package main;

import util.Util;
import modulos.Marking;
import modulos.Morphology;
import modulos.PreProcessing;


public class Main {
	static final String DIRETORIO_PREPROCESSING = "\\preprocessing\\";
	static final String DIRETORIO_MARKING = "\\marking\\";
	static final String DIRETORIO_MORHOLOGY = "\\morphology\\";
	static final String EXEMPLO = "base\\exemplo";
	static final String BACKGROUND_IMAGE = "base\\background\\background25.jpg";
	static final String FOREGROUND_IMAGE = "\\foreground\\foreground25.jpg";
	
	public static void main(String[] args) {
		
		int qtdExemplos = 7;
		
		System.out.println("iniciando o programa.");
		
		try {
			
			for(int i=1;i<=qtdExemplos;i++)
			{
				double[][][] background_colorido = Util.lerImagemColorida(BACKGROUND_IMAGE);
				double[][] background_cinza = PreProcessing.imageGraying(background_colorido);
				
				double[][][] foreground_colorido = Util.lerImagemColorida(EXEMPLO+i + FOREGROUND_IMAGE);
				double[][] foreground_cinza = PreProcessing.imageGraying(foreground_colorido);

				for(int threshold=80;threshold<=80;threshold+=10)
				{					
					double[][] preprocessed = PreProcessing.start(EXEMPLO+i+DIRETORIO_PREPROCESSING, background_cinza, foreground_cinza, threshold);
					
					for(int qtdDilatacoes=1;qtdDilatacoes<=1;qtdDilatacoes++)
					{
						double[][] fixed = Morphology.start(EXEMPLO+ i + DIRETORIO_MORHOLOGY, preprocessed, threshold, qtdDilatacoes);
						Marking.start(EXEMPLO + i + DIRETORIO_MARKING, foreground_colorido, fixed, threshold, qtdDilatacoes);
					}					
				}
			}
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		finally	{
			System.out.println("fim do processo.");
		}
		
	}
}
